using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace SharpPieces.DemoApp.SharpPiecesWebControls.ExtendedDropDownList
{

    public partial class DataBinding : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //databind time
            DataTable dt = new DataTable();
            dt.Columns.Add("Text");
            dt.Columns.Add("Value");
            dt.Columns.Add("GroupText");

            dt.Rows.Add("Text 1.1", "Value 1.1", "1");
            dt.Rows.Add("Text 1.2", "Value 1.2", "1");
            dt.Rows.Add("Text 2.1", "Value 2.1", "2");
            dt.Rows.Add("Text 1.3", "Value 1.3", "1");

            //null or empty string is interpreted as no group!
            dt.Rows.Add("No Group", "Value", "");

            ddl.DataSource = dt;
            ddl.DataTextField = "Text";
            ddl.DataValueField = "Value";
            ddl.DataGroupField = "GroupText";

            ddl.DataBind();

            ddl2.DataSource = dt;
            ddl2.DataTextField = "Text";
            ddl2.DataValueField = "Value";

            ddl2.DataBind();
            
        }
    }
}
